import mock from 'mockjs'
mock.setup({
  timeout: '200-600'
})
const getUserInfo = mock.mock(
  'needLogin/getUserInfo',
  'post',
  options => {
    const {
      token
    } = JSON.parse(options.body)
    let success = 'false'
    let [errorMsg, errorCode] = ['', '']
    if (token !== '123456789') {
      success = 'false'
      errorMsg = '登录过期'
      errorCode = 'expired'
    } else {
      success = 'true'
    }
    if (success === 'false') {
      return {
        success,
        errorCode,
        errorMsg
      }
    } else {
      return {
        success,
        data: {
          info: {
            name: '莫子希',
            avatar: './static/img/mine/user.jpg',
            content: '一个低调的人'
          }
        }
      }
    }
  }
)
export default getUserInfo
